﻿@{
    ViewBag.Title = "商品管理--查看商品";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<link href="~/Content/js/simditor/css/simditor.css" rel="stylesheet" />
<script src="~/Content/js/simditor/js/module.min.js"></script>
<script src="~/Content/js/simditor/js/hotkeys.min.js"></script>
<script src="~/Content/js/simditor/js/simditor.min.js"></script>

<link href="~/Content/css/gray/easyui.css" rel="stylesheet" type="text/css" />

<!--商品规格
<script src="~/Content/js/jquery/product-sku-jquery.js" type="text/javascript"></script>-->
<style>
    /*商品规格*/
    #contetSKUs h2 {
        border-bottom: 1px solid #ccc;
        font-size: 14px;
        line-height: 30px;
        margin: 10px 0 10px 45px;
        width: 85%;
    }
     #AttributeContent {
        list-style-type: none;
    }

    #AttributeContent li {
        line-height: 30px;
        vertical-align: middle;
    }

        #AttributeContent li input {
            margin-right: 5px;
        }

    #AttributeContent li {
        float: left;
        width: 150px;
        display: block;
    }
     /*文本编辑器高度*/
    .simditor .simditor-body , .editor-style{
      min-height:450px;
    }
</style>

<script>
    var editor;
    var keyValue = $.request("keyValue");
   
    $(function () {
      
        editor = new Simditor({
            textarea: $('#F_Description'),
            toolbar: ['title', 'bold', 'italic', 'underline', 'strikethrough', 'color', '|', 'ol', 'ul', 'blockquote', 'code', 'table', '|', 'link', 'image', 'hr', '|', 'indent', 'outdent']
        });
        editor.Width = 1000;

        if (!!keyValue) {
            $.ajax({
                url: "/ProductManage/Product/GetFormInfo",
                data: { keyValue: keyValue },
                dataType: "json",
                cache: false,
                async: false,
                success: function (data) {
                    $("#form1").formSerialize(data); 
                    editor.setValue(data["F_Description"]);

                    //设置商品属性值
                   // getAttribute(data.ProductattrList, data.attrList);
                   
                    //设置商品图片
                    if (data.F_ImageUrl != null && data.F_ImageUrl != "") {
                        $("#pic_view").attr("src", data.F_ImageUrl);
                    }
                    //商品其他图片
                    if (data.NotMapped_ImagesUrl != null) {
                        $.each(data.NotMapped_ImagesUrl, function (n, value) {
                            $("#pic_view" + (n + 1)).attr("src", value);
                        }
                       );
                    }
                    //如果存在规格信息，则加载规格信息
                   // $("#productID").val(data.F_Id);
                    //if (data.SkuItemCount > 0) {
                    //    GeneratedSpecification(data.F_TypeId);
                    //}
                    //禁用
                    $("#contetSKUs").find('input[type="checkbox"]').attr('disabled', 'disabled');
                    $("#form1").find('input[type="text"]').attr('readonly', 'readonly');
                    //禁用编辑控件
                    $(".simditor-body").attr("contenteditable","false");
                }
            });
        }
    });

    //根据商品类型获取属性 设置属性值  attrList:属性集合 valueList：属性值集合
    /*function getAttribute(attrList,valueList) {
        if (attrList != null) {
            var showtype = "radio";
            //循环显示属性
            for (var i = 0; i < attrList.length; i++) {
                var model = attrList[i];
                var row = '<tr id="' + model.F_Id + '" style="border-bottom:1px solid rgb(191,191,191); height:40px" name=' + model.F_UsageMode + '>';
                row += '<td style="border:none;width:10%;text-align:right">' + model.F_AttributeName + '：</td>';
                row += "<td style='text-align:left;'>";

                if (model.F_UsageMode == 2) //自定义填写
                {
                    row += "<input class='form-control' style='margin-left:10px;width:200px' type='text' readonly />";
                } else {
                    if (model.F_UsageMode == 1) //多选
                        showtype = "checkbox";
                    for (var j = 0; j < model.valueList.length; j++) {
                        var attrValue = model.valueList[j];
                        row += "<input style='margin-left:10px' disabled type='" + showtype + "' name='" + showtype + i + "'  value='" + attrValue.F_Id + "'/>&nbsp;&nbsp;" + attrValue.F_ValueStr;
                    }
                }
                row += "</td></tr>";
                $("#tableAttribute").append(row);
            }
            if (valueList != null) {
                for (var b = 0; b < valueList.length; b++) {
                    var productAttr = valueList[b];
                    //属性tr
                    var curAttrTr = $("#tableAttribute tr[id='" + productAttr.F_AttributeId + "']");
                    if (curAttrTr.attr("name") == 0)//单选
                    {
                        if (productAttr.F_ValueId != null)
                            curAttrTr.find("input[type='radio'][value='" + productAttr.F_ValueId + "']").attr('checked', 'checked');
                    } else if (curAttrTr.attr("name") == 1)//多选
                    {
                        curAttrTr.find("input:checkbox[value='" + productAttr.F_ValueId + "']").attr('checked', 'true');
                    } else if (curAttrTr.attr("name") == 2)//自定义
                    {
                        curAttrTr.find("input[type='text']").val(productAttr.F_ValueId);
                    }
                }
            }
        }
    }
   */
</script>
<form id="form1">
      <ul class="nav nav-tabs" role="tablist">
            <li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">基本信息</a></li>
            <li role="presentation" ><a href="#message" aria-controls="message" role="tab" data-toggle="tab">详细介绍</a></li>
            @*<li role="presentation" ><a href="#guige" aria-controls="guige" role="tab" data-toggle="tab">规格</a></li>*@
       </ul>
  <div class="tab-content">
    <div role="tabpanel" style="margin-right: 20px;" class="tab-pane active" id="home">
        <table class="form">
               @*<tr>
                    <th class="formTitle">商品分类</th>
                    <td class="formValue" colspan="3" >
                        <input id="CategoryNames" name="CategoryNames" class=" form-control" type="text">
                    </td>
                </tr>*@
            <tr>
                <th class="formTitle">商品名称</th>
                <td class="formValue" colspan="3">
                    <input id="F_ProductName" name="F_ProductName" type="text" class="form-control "  />
                </td>
            </tr>
              @*<tr>
            <th class="formTitle">商品类型</th>
            <td class="formValue">
                 <input id="TypeName" name="TypeName" type="text" class="form-control "  />
                </td>
                 <th class="formTitle">品牌</th>
                 <td class="formValue">
                      <input id="F_BrandId" name="F_BrandId" type="text" class="form-control "  />
            </td>
        </tr>
    <tr>
        <th></th>
        <td colspan="3">
               <table id="tableAttribute"  style="width:98%;">
             </table>
        </td>
    </tr>*@
              <tr>
                <th class="formTitle">商品编码</th>
                <td class="formValue">
                    <input id="F_ProductCode" name="F_ProductCode" type="text" class="form-control " />
                </td>
                   <th class="formTitle">商品库存</th>
                <td class="formValue">
                    <input id="F_Stock" name="F_Stock" type="text" class="form-control "  />
                </td>
            </tr>
             <tr>
                  <th class="formTitle">销售价</th>
                <td class="formValue">
                    <input id="F_Price" name="F_Price " type="text" class="form-control " />
                </td>
                    <th class="formTitle">计量单位</th>
                <td class="formValue">
                    <input id="F_Unit" name="F_Unit" type="text" class="form-control" />
                </td>
               
            </tr>
           
              <tr>
                <th class="formTitle">市场价</th>
                <td class="formValue">
                    <input id="F_MarketPrice" name="F_MarketPrice" type="text" class="form-control" />
                </td>
                <th class="formTitle">成本价</th>
                <td class="formValue">
                    <input id="F_LowestPrice" name="F_LowestPrice" type="text" class="form-control" />
                </td>
            </tr>
              <tr> 
                    <th class="formTitle">销售数量</th>
                <td class="formValue">
                    <input id="F_SaleCounts" name="F_SaleCounts" type="text" class="form-control" />
                </td>
                    <th class="formTitle">显示排序</th>
                <td class="formValue">
                    <input id="F_SortCode" name="F_SortCode" type="text" class="form-control "  />
                </td>
             
            </tr>
              <tr>
                <th class="formTitle">是否促销</th>
                <td class="formValue">
                    <div class="ckbox">
                        <input id="F_Promotion" name="F_Promotion" type="checkbox"><label for="F_Promotion">是</label>
                    </div>
                </td>
                <th class="formTitle">促销价</th>
                <td class="formValue">
                    <input id="F_PromotionPrice" name="F_PromotionPrice " type="text" class="form-control"/>
                </td>
            </tr>
             <tr>
                  <th class="formTitle">是否上架</th>
                <td class="formValue" colspan="3">  
                    <div class="ckbox"> 
                        <input id="F_EnabledMark" name="F_EnabledMark" type="checkbox" disabled><label for="F_EnabledMark">是</label>
                    </div>
                </td>
            </tr>
            <tr>
                <th class="formTitle">商品图片</th>
                <td class="formValue"  colspan="3" id="tdImage">
                    <div class="row">
                      <div class="col-xs-2" >
                        <img src="/Content/img/imgdefalt.jpg" width="150" height="150" id="pic_view"  />
                      </div>
                     <div class="col-xs-2" style="margin-left:20px">
                         <img src="/Content/img/imgdefalt.jpg" width="150" height="150" id="pic_view1"  />
                     </div> 
                     <div class="col-xs-2"  style="margin-left:20px">
                         <img src="/Content/img/imgdefalt.jpg" width="150" height="150" id="pic_view2" />
                       </div>  
                      <div class="col-xs-2"  style="margin-left:20px">
                             <img src="/Content/img/imgdefalt.jpg" width="150" height="150" id="pic_view3" /> 
                       </div>
                         <div class="col-xs-2"  style="margin-left:20px">
                             <img src="/Content/img/imgdefalt.jpg" width="150" height="150" id="pic_view4" /> 
                        </div>
                    </div>
                </td>
            </tr>
        </table>
    </div>
      
    <div role="tabpanel" style="margin-right: 20px;" class="tab-pane " id="message">
      @*  @Html.Partial("GuigeView")*@
         <table class="form">
          <tr>
                <th class="formTitle" valign="top" style="padding-top: 5px;">
                    描述
                </th>
                <td class="formValue">
                    <textarea id="F_Description" name="F_Description" class="form-control" ></textarea>
                </td>
            </tr>
        </table>
    </div>
    @*<div role="tabpanel" style="margin-right: 20px;" class="tab-pane" id="guige">
    <input type="hidden" id="hfCurrentBaseProductSKUs" value="" />
        <table  class="form"  style="margin:20px">
         <input type="hidden" id="productID"  />
            <tr class="SKUsTR">
                <td id="contetSKUs" colspan="2"></td>
            </tr>
        </table>
    </div>*@
  </div>
</form>